import Taro from '@tarojs/taro'
import { postFeedback } from './service';

export default {

  namespace: 'feedback',

  state: {},

  effects: {
    * init({payload:value}, { call,put }) {
      console.log('feedback effects value', value);
      const response = yield call(postFeedback,value);
      console.log('mine effects response', response);
      if(response){
        Taro.showToast({
            title: '反馈成功',
            icon: 'succes',
            duration: 2000,
          });
        yield put({
            type:'save',
            payload: {response}
          });
      }
    },

  },

  reducers: {
    save(state, { payload }) {
      console.log('home effects payload',payload);
      return {
        ...state,
        ...payload
      };
    },
  },
};
